package com.lj.universalframework.ui.viewModel

import android.util.Log
import androidx.lifecycle.MutableLiveData
import com.lj.universalframework.base.ResponseEntity
import com.lj.universalframework.http.RequestViewModel

class MainViewModel : RequestViewModel() {

    var name = MutableLiveData("获取验证码")

    /**
     * 获取验证码
     */
    fun loadDSL() {
        apiRequest<ResponseEntity<String>>({
            onRequest {
                service.newLessonBoxRenew()
            }
            onResponse {
                Log.i("测试一下", "请求结果${it.msg}")
            }

            onError {
                var type = onErrorType(it)
                Log.i("测试一下", "onError$it")
            }
        })
    }

    /**
     * 登录
     */
    fun logIn() {
        apiRequest<ResponseEntity<String>>({
            onRequest {
                service.logIn("17363812956", "123456")
            }
            onResponse {
                Log.i("测试一下", "请求结果${it.msg}")
            }
        })
    }

    fun cs03() {
        name.value = "你才我是什么"
    }
}